// 跳转到新的页面
import router from "@/router";
// import {getSessionItem, setSessionItem} from "@/utils/auth";
import Vue from "vue";
export function uniJumpRoute(path,query){
    if (path===-1){
        router.go(-1)
    }else{
        router.push({path:path,query}).catch(err=>{})
    }
}

// 防止重复提交的
Vue.directive('debounce', {
    inserted(el, binding) {
        let throttleTime = parseInt(binding.value) || 2000
        el.addEventListener('click', () => {
            if (!el.disabled) {
                el.disabled = true
                setTimeout(() => {
                    el.disabled = false
                }, throttleTime)
            }
        })
    }
})


// 路由跳转
Vue.directive('routers', {
    inserted(el, data) {
        el.addEventListener('click', () => {
            uniJumpRoute(data.value.path,data.value.query)

        })
    }
})

